package p270jp.pxv.android.activity;

import android.content.ComponentCallbacks;
import android.content.Context;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.google.android.material.appbar.MaterialToolbar;
import net.pixiv.charcoal.android.view.charcoalSwitch.CharcoalSwitch;
import p014ae.AbstractActivityC0082g2;
import p014ae.C0098j6;
import p047bg.C1124a;
import p062c4.ViewBindings;
import p064c6.Preconditions;
import p189gn.AbstractC3435a;
import p216hn.Lambda;
import p216hn.Reflection;
import p236ih.YufulightSettingService;
import p270jp.pxv.android.R;
import p314lg.ActivityOptoutSettingsBinding;
import p325m0.MutabilityOwnership;
import p374nm.EmbeddedLinkClickableSpan;
import p452qn.C5859m;
import p579vo.Qualifier;
import p603wm.AbstractC6949c;

/* compiled from: OptoutSettingsActivity.kt */
/* renamed from: jp.pxv.android.activity.OptoutSettingsActivity */
/* loaded from: classes2.dex */
public final class OptoutSettingsActivity extends AbstractActivityC0082g2 {

    /* renamed from: K */
    public static final /* synthetic */ int f18491K;

    /* renamed from: I */
    public ActivityOptoutSettingsBinding f18492I;

    /* renamed from: J */
    public final AbstractC6949c f18493J = Preconditions.m9802P(1, new C4054b(this, null, null));

    /* compiled from: OptoutSettingsActivity.kt */
    /* renamed from: jp.pxv.android.activity.OptoutSettingsActivity$a */
    /* loaded from: classes2.dex */
    public static final class C4053a extends EmbeddedLinkClickableSpan {
        public C4053a(int i) {
            super(i);
        }

        @Override // android.text.style.ClickableSpan
        public void onClick(View view) {
            MutabilityOwnership.m3745m(view, "widget");
            Context context = view.getContext();
            MutabilityOwnership.m3746l(context, "widget.context");
            C1124a.m10213A(context, "https://www.pixiv.net/optout/?appname=pixiv_android");
        }
    }

    /* compiled from: ComponentCallbackExt.kt */
    /* renamed from: jp.pxv.android.activity.OptoutSettingsActivity$b */
    /* loaded from: classes2.dex */
    public static final class C4054b extends Lambda implements AbstractC3435a<YufulightSettingService> {

        /* renamed from: a */
        public final /* synthetic */ ComponentCallbacks f18494a;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        public C4054b(ComponentCallbacks componentCallbacks, Qualifier aVar, AbstractC3435a aVar2) {
            super(0);
            this.f18494a = componentCallbacks;
        }

        /* JADX WARN: Type inference failed for: r0v4, types: [ih.a, java.lang.Object] */
        @Override // p189gn.AbstractC3435a
        public final YufulightSettingService invoke() {
            return C1124a.m10173s(this.f18494a).f24118a.m920a().m621a(Reflection.m5499a(YufulightSettingService.class), null, null);
        }
    }

    /* renamed from: V0 */
    public final YufulightSettingService m4777V0() {
        return (YufulightSettingService) this.f18493J.getValue();
    }

    @Override // p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        View inflate = getLayoutInflater().inflate(R.layout.activity_optout_settings, (ViewGroup) null, false);
        int i = R.id.footer_text_view;
        TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.footer_text_view);
        if (textView != null) {
            i = R.id.optout_switch;
            CharcoalSwitch charcoalSwitch = (CharcoalSwitch) ViewBindings.m9835b(inflate, R.id.optout_switch);
            if (charcoalSwitch != null) {
                i = R.id.title_text_view;
                TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.title_text_view);
                if (textView2 != null) {
                    i = R.id.tool_bar;
                    MaterialToolbar materialToolbar = (MaterialToolbar) ViewBindings.m9835b(inflate, R.id.tool_bar);
                    if (materialToolbar != null) {
                        LinearLayout linearLayout = (LinearLayout) inflate;
                        this.f18492I = new ActivityOptoutSettingsBinding(linearLayout, textView, charcoalSwitch, textView2, materialToolbar);
                        setContentView(linearLayout);
                        ActivityOptoutSettingsBinding t0Var = this.f18492I;
                        if (t0Var != null) {
                            C1124a.m10197Q(this, t0Var.f22269e, R.string.settings_optout);
                            ActivityOptoutSettingsBinding t0Var2 = this.f18492I;
                            if (t0Var2 != null) {
                                t0Var2.f22268d.setText(getString(R.string.settings_optout));
                                String string = getString(R.string.settings_optout_footer);
                                String string2 = getString(R.string.settings_optout_footer_link);
                                MutabilityOwnership.m3746l(string2, "getString(jp.pxv.android…tings_optout_footer_link)");
                                TypedValue typedValue = new TypedValue();
                                if (getTheme().resolveAttribute(R.attr.colorCharcoalBrand, typedValue, true)) {
                                    C4053a aVar = new C4053a(typedValue.data);
                                    MutabilityOwnership.m3746l(string, "text");
                                    SpannableString spannableString = new SpannableString(string);
                                    int J = C5859m.m2737J(string, string2, 0, false, 6);
                                    if (J >= 0) {
                                        spannableString.setSpan(aVar, J, string2.length() + J, 18);
                                    }
                                    ActivityOptoutSettingsBinding t0Var3 = this.f18492I;
                                    if (t0Var3 != null) {
                                        t0Var3.f22266b.setText(spannableString);
                                        ActivityOptoutSettingsBinding t0Var4 = this.f18492I;
                                        if (t0Var4 != null) {
                                            t0Var4.f22266b.setMovementMethod(LinkMovementMethod.getInstance());
                                            ActivityOptoutSettingsBinding t0Var5 = this.f18492I;
                                            if (t0Var5 != null) {
                                                t0Var5.f22267c.setChecked(m4777V0().m5145b());
                                                ActivityOptoutSettingsBinding t0Var6 = this.f18492I;
                                                if (t0Var6 != null) {
                                                    t0Var6.f22267c.setOnCheckedChangeListener(new C0098j6(this, 0));
                                                    return;
                                                } else {
                                                    MutabilityOwnership.m3737u("binding");
                                                    throw null;
                                                }
                                            } else {
                                                MutabilityOwnership.m3737u("binding");
                                                throw null;
                                            }
                                        } else {
                                            MutabilityOwnership.m3737u("binding");
                                            throw null;
                                        }
                                    } else {
                                        MutabilityOwnership.m3737u("binding");
                                        throw null;
                                    }
                                } else {
                                    throw new IllegalStateException("Charcoal Theme, もしくは Charcoal Bridge Theme を利用してください");
                                }
                            } else {
                                MutabilityOwnership.m3737u("binding");
                                throw null;
                            }
                        } else {
                            MutabilityOwnership.m3737u("binding");
                            throw null;
                        }
                    }
                }
            }
        }
        throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        MutabilityOwnership.m3745m(menuItem, "item");
        if (menuItem.getItemId() != 16908332) {
            return super.onOptionsItemSelected(menuItem);
        }
        this.f940i.m12030b();
        return true;
    }
}
